<%/**
			 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
			 *
			 * This library is free software; you can redistribute it and/or modify it under
			 * the terms of the GNU Lesser General Public License as published by the Free
			 * Software Foundation; either version 2.1 of the License, or (at your option)
			 * any later version.
			 * 
			 * This library is distributed in the hope that it will be useful, but WITHOUT
			 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
			 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
			 * details.
			 */%>

<%@ include file="/init.jsp" %>
<%@page import="base.MovieInfo" %>
<%@page import="database.ConnectionDB" %>
<%@page import="gui.UserInterface"%>
<%@page import="com.liferay.portal.kernel.util.GetterUtil" %>

<portlet:actionURL var="changeAction" name="ChangeAction">
    <portlet:param name="nextView" value="" />
</portlet:actionURL>

<portlet:actionURL var="searchAction" name="SearchAction">
	<portlet:param name="nextView" value="searchresultForm"></portlet:param>
</portlet:actionURL>

<c:if test="${! empty param.msg }">
    <p style="color:red">${param.msg}</p>
</c:if>

<aui:form method="post" action="${searchAction}">
	<aui:input label="Search Movies from IMDB" name="movieTitleInput" type="text" ></aui:input>
	<aui:input label="Year (optional)" name="movieYearInput" type="text"></aui:input>
	<aui:button type="Submit" value="Search"></aui:button>
</aui:form>

<%
	/** =====================TABLE - LIST OF MOVIES==========================*/
%>
<form action="<%= changeAction %>" method="post">
<%
	/** =====================TABLE - LIST OF MOVIES==========================*/
%>
<%
 	List list = (List) request.getAttribute("liferay-ui:table-iterator:list");
 	int listPos = GetterUtil.getInteger((String) request.getAttribute("liferay-ui:table-iterator:listPos"));
 %> 
 <liferay-ui:table-iterator
			list="${movieList}"
			listType="MovieInfo"
			rowLength="5"
			rowPadding="10px"
			rowValign="top"
			width="100%"
			>
				<c:if test="<%=listPos==0%>">
					<%
						listPos = listPos + 1;
					%>
					<tr align="left">
						<th style="padding: 4px 8px 10px 8px;"><b>Title</b></th>
						<th style="padding: 4px 8px 10px 8px;"><b>Genre</b></th>
						<th style="padding: 4px 8px 10px 8px;"><b>Year</b></th>
						<th style="padding: 4px 8px 10px 8px;"><b>Link</b></th>
						<th style="padding: 4px 8px 10px 8px;"><b>Action</b></th>
					</tr>
				</c:if>
			<tr align="left">
				<td style="padding: 4px 8px 10px 8px;">
					<%=tableIteratorObj.getTitle()%>
				</td>
				<td style="padding: 4px 8px 10px 8px;">
					<%=tableIteratorObj.getGenre()%>
				</td>
				<td style="padding: 4px 8px 10px 8px;">
					<%=tableIteratorObj.getYear()%>
				</td>
				<td style="padding: 4px 8px 10px 8px;">
					<a href="<%=tableIteratorObj.getDetails().getLinkToIMDB()%>"><%=tableIteratorObj.getDetails().getLinkToIMDB()%></a>
				</td>
				<td style="padding: 4px 8px 10px 8px;"> 
					<input type="submit" name="movieDeleteId<%=tableIteratorObj.getMovieId()%>" value="Delete"/>
					<input type="submit" name="movieDetailId<%=tableIteratorObj.getMovieId()%>" value="Update"/>
				</td>
			</tr>
</liferay-ui:table-iterator>
</form>